import os
import sys
from subprocess import *
from paramsetup import Param

class Executer(object):    
    tcsuiteConfig = ''
    testcase = ''
    
    def run():
        root_dir = sys.path[0]
        
        Param.testcasefolder = root_dir+'\\testcases'
        pathtoTCfolder = Param.testcasefolder
        
        print "Param.testcasefolder=" +Param.testcasefolder
        print 'pathtoTCfolder='+pathtoTCfolder
        tcsuiteConfig = pathtoTCfolder + '\\testcases.txt'
        print "tcsuiteConfig="+tcsuiteConfig
        f = open( tcsuiteConfig ,'r')
        
        print 'start to readlines...'    
        for line in f.readlines():        
            testcase = pathtoTCfolder + line            
            print 'testcase=' + testcase
            if Executer.__hasTestCase(testcase):
#                p = Popen(line)      
                p = os.system('python ' + testcase)
#                p = open(testcase).readlines()
                print "******************p",p
            else:
                print "not find file:",testcase

    def __hasTestCase(testcase):
        return os.path.isfile(testcase)
     
    run           = staticmethod(run)
    __hasTestCase = staticmethod(__hasTestCase)       

    
if __name__ =='__main__':
        
    Executer.run()
